//
//  GrowRecordDetailFooterView.m
//  PigMarket
//
//  Created by mac on 2019/7/4.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "GrowRecordDetailFooterView.h"

@implementation GrowRecordDetailFooterView

#pragma mark - init method
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.leftTitle];
    [self addSubview:self.confirmBtn];
}

- (void)initLayout {
    // 布局子控件
    [self.leftTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.top.bottom.mas_equalTo(0);
    }];
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.mas_equalTo(0);
        make.width.mas_equalTo(125);
    }];
}

#pragma mark - getter and setter
- (void)setPrice:(NSString *)price {
    _price = price;
   
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:price];
    text.yy_font = [UIFont systemFontOfSize:16];
    text.yy_color = [UIColor colorWithHexString:@"#F25C62"];
    [text yy_setFont:[UIFont systemFontOfSize:13] range:NSMakeRange(0, 5)];
    [text yy_setColor:[UIColor colorWithHexString:@"#5E5E5E"] range:NSMakeRange(0, 5)];
    [text yy_setFont:[UIFont systemFontOfSize:13] range:NSMakeRange(5, 1)];
    self.leftTitle.attributedText = text;
}
- (YYLabel *)leftTitle {
    if (!_leftTitle) {
        _leftTitle = [[YYLabel alloc] init];
    }
    return _leftTitle;
}
- (UIButton *)confirmBtn {
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_confirmBtn setTitle:@"立即支付" forState:UIControlStateNormal];
        [_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_confirmBtn setBackgroundImage:[UIImage imageNamed:@"adopt_adoptdetail_confirm"] forState:UIControlStateNormal];
    }
    return _confirmBtn;
}

@end
